package com.tjp.eight.ui.fragment.modysec;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.ResultModel;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;
import com.tjp.eight.utils.AppUtils;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/3/7.
 */
public class ModyPresenter extends BasePresenterImpl<ModyView> {
    private ModyService service = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(ModyService.class);

    public ModyPresenter(ModyView view) {
        attachView(view);
    }

    public void modifypass(String mJson) {
        RequestBody requestBody = AppUtils.getRequestBody(mJson);
        addSubscription(service.modyp(requestBody), new SubscribeCallBack<>(new NetCallBack<ResultPWModel>() {
            @Override
            public void onSuccess(ResultPWModel model) {
                view.modyPSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {

            }

            @Override
            public void onCompleted() {

            }
        }));
    }

    public void modifypassgetcode(String sJson) {
        RequestBody requestBody = AppUtils.getRequestBody(sJson);
        addSubscription(service.modypcode(requestBody), new SubscribeCallBack<ResultModel>(new NetCallBack<ResultModel>() {
            @Override
            public void onSuccess(ResultModel model) {
                view.modySuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {

            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
